#!/bin/sh

# find SN base installation directory
snbindir=`dirname $0`
snbasedir=`cd $snbindir/.. ; pwd`
startup=hyper
script=snpdbg

# find the main "hyper" executable
for dir in libexec/snavigator libexec bin; do
	try="$snbasedir/$dir/$startup"
  	run=""
	
	#echo "testing for: $try"
	if test -f "$try"; then
		run="$try"
		break
	fi
done
#echo "debug: found $startup at $run"


# find the desired script
for dir in share/snavigator/etc share/snavigator share/etc; do
	try="$snbasedir/$dir/$script"
  	runscript=""

	#echo "testing for: $try"
	if test -f "$try"; then
		runscript="$try"
		break
	fi
done              	
#echo "debug: found $script at $runscript"


# uncomment the following to run in debugger
#echo "set args -file "$runscript" ${1+"$@"}" > gdb.run
#gdb --command gdb.run $run

# ordinary startup 
exec "$run" --home "$snbasedir" -file "$runscript" ${1+"$@"}
